<template>
	<view class="u-common-shadow u-back-white u-p-t-28 u-p-r-32 u-p-b-30 u-p-l-28">
		<view v-for="(items, index) in chatList.records" :key="index" class="">
			<view class="s-flex">
				<u-avatar @click.native.stop="handleGoUserDetail(items.user_id)" :src="items.head_img">
				</u-avatar>
				<view class="u-m-l-16 u-width-100">
					<view class="">
						<text class="font_weight_bold u-font-24 u-p-r-16">{{ items.username }}</text>
						<text v-if="items.is_group_owner == 1"
							class="tag_yellow u-font-22 u-p-l-16 u-p-r-16 u-p-t-4 u-p-b-4">发布人</text>
					</view>
					<view class="u-m-t-30 font6769">{{ items.content }}</view>
					<view class="u-m-t-36 u-flex u-row-between">
						<text class="u-font-999 u-font-22">{{ items.datetime }}</text>
						<view v-show="chatList.is_docking == 1 && chatList.demand_status == '1'"
							@click="handleLeave(items.record_id)" class="u-font-24 u-type-primary">
							<text>回复</text>
							<u-icon class="u-p-l-10" name="chat" color="#fb6316" size="28"></u-icon>
						</view>
					</view>
					<view v-for="(chilItem, chiIndex) in items.records_child" :key="chiIndex"
						class="u-common-shadow u-m-t-20 u-radius-10 u-p-t-28 u-p-r-32 u-p-b-30 u-p-l-28">
						<view class="u-flex">
							<u-avatar size="mini" :src="chilItem.head_img" />
							<view class="u-m-l-20">
								<view class="">
									<text class="u-font-bold u-font-24 u-p-r-16">{{ chilItem.username }}</text>
									<text v-if="chilItem.is_group_owner == 1"
										class="tag_yellow u-font-22 u-p-l-16 u-p-r-16 u-p-t-4 u-p-b-4">发布人</text>
								</view>
								<text class="u-font-22">{{ chilItem.content }}</text>
							</view>
						</view>
					</view>

				</view>
			</view>
			<u-line v-show="(chatList.records && chatList.records.length) != Number(index+1)" margin="26rpx 0 28rpx 0"
				color="#EAEAEAFF" />
		</view>
	</view>
</template>

<script>
	import { throttle } from "@/utils/index.js"
	export default {
		props: ['chatList'],
		data() {
			return {}
		},
		methods: {
			handleLeave(pid) {
				this.$emit("leaveMessage", pid)
			},
			handleGoUserDetail(id) {
				uni.navigateTo({
					url: `/pages/contactDetail/contactDetail?id=${id}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.talk_down_bg {
		background-color: #F6F6F6FF;
	}

	.talk_width {
		width: 85%;
	}
	
	.tag_yellow {
		border-radius: 10px 10px 10px 0px;
		background-color: #FFAA02FF;
		color: #fff;
	}
</style>
